/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.inventory.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author sithum
 */
@Entity
@Table(name = "ITEM", catalog = "", schema = "APP", uniqueConstraints = {@UniqueConstraint(columnNames = {"ITEM_CODE"})})
@NamedQueries({@NamedQuery(name = "Item.findAll", query = "SELECT i FROM Item i"), @NamedQuery(name = "Item.findByItemId", query = "SELECT i FROM Item i WHERE i.itemId = :itemId"), @NamedQuery(name = "Item.findByItemCode", query = "SELECT i FROM Item i WHERE i.itemCode = :itemCode"), @NamedQuery(name = "Item.findByItemName", query = "SELECT i FROM Item i WHERE i.itemName = :itemName"), @NamedQuery(name = "Item.findByDiscountStatus", query = "SELECT i FROM Item i WHERE i.discountStatus = :discountStatus"), @NamedQuery(name = "Item.findByFreeIssueStatus", query = "SELECT i FROM Item i WHERE i.freeIssueStatus = :freeIssueStatus"), @NamedQuery(name = "Item.findByPrice", query = "SELECT i FROM Item i WHERE i.price = :price"), @NamedQuery(name = "Item.findByReorderLevel", query = "SELECT i FROM Item i WHERE i.reorderLevel = :reorderLevel"), @NamedQuery(name = "Item.findByBaseUnit", query = "SELECT i FROM Item i WHERE i.baseUnit = :baseUnit"),
@NamedQuery(name = "Item.recordCount", name = "SELECT COUNT(i) FROM Item i")})
public class Item implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ITEM_ID", nullable = false)
    private Integer itemId;
    @Basic(optional = false)
    @Column(name = "ITEM_CODE", nullable = false, length = 20)
    private String itemCode;
    @Basic(optional = false)
    @Column(name = "ITEM_NAME", nullable = false, length = 100)
    private String itemName;
    @Lob
    @Column(name = "ITEM_IMAGE")
    private Serializable itemImage;
    @Basic(optional = false)
    @Column(name = "DISCOUNT_STATUS", nullable = false, length = 10)
    private String discountStatus;
    @Basic(optional = false)
    @Column(name = "FREE_ISSUE_STATUS", nullable = false, length = 10)
    private String freeIssueStatus;
    @Basic(optional = false)
    @Column(name = "PRICE", nullable = false, precision = 8, scale = 2)
    private BigDecimal price;
    @Basic(optional = false)
    @Column(name = "REORDER_LEVEL", nullable = false)
    private int reorderLevel;
    @Basic(optional = false)
    @Column(name = "BASE_UNIT", nullable = false)
    private int baseUnit;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "itemId")
    private List<LineItem> lineItemCollection;
    @OneToMany(mappedBy = "itemId")
    private List<MarketReturn> marketReturnCollection;
    @JoinColumn(name = "CATEGORY_ID", referencedColumnName = "CATEGORY_ID")
    @ManyToOne
    private Category categoryId;
    @JoinColumn(name = "DISCOUNTS_ID", referencedColumnName = "DISCOUNTS_ID")
    @ManyToOne
    private Discounts discountsId;
    @JoinColumn(name = "FREE_ISSUE_ID", referencedColumnName = "FREE_ISSUE_ID")
    @ManyToOne
    private FreeIssues freeIssueId;
    @JoinColumn(name = "WEIGHT_ID", referencedColumnName = "WEIGHT_ID", nullable = false)
    @ManyToOne(optional = false)
    private ItemWeight weightId;
    @OneToMany(mappedBy = "itemId")
    private List<Damaged> damagedCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "itemId")
    private List<ItemDetails> itemDetailsCollection;

    public Item() {
    }

    public Item(Integer itemId) {
        this.itemId = itemId;
    }

    public Item(Integer itemId, String itemCode, String itemName, String discountStatus, String freeIssueStatus, BigDecimal price, int reorderLevel, int baseUnit) {
        this.itemId = itemId;
        this.itemCode = itemCode;
        this.itemName = itemName;
        this.discountStatus = discountStatus;
        this.freeIssueStatus = freeIssueStatus;
        this.price = price;
        this.reorderLevel = reorderLevel;
        this.baseUnit = baseUnit;
    }

    public Integer getItemId() {
        return itemId;
    }

    public void setItemId(Integer itemId) {
        this.itemId = itemId;
    }

    public String getItemCode() {
        return itemCode;
    }

    public void setItemCode(String itemCode) {
        this.itemCode = itemCode;
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public Serializable getItemImage() {
        return itemImage;
    }

    public void setItemImage(Serializable itemImage) {
        this.itemImage = itemImage;
    }

    public String getDiscountStatus() {
        return discountStatus;
    }

    public void setDiscountStatus(String discountStatus) {
        this.discountStatus = discountStatus;
    }

    public String getFreeIssueStatus() {
        return freeIssueStatus;
    }

    public void setFreeIssueStatus(String freeIssueStatus) {
        this.freeIssueStatus = freeIssueStatus;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public int getReorderLevel() {
        return reorderLevel;
    }

    public void setReorderLevel(int reorderLevel) {
        this.reorderLevel = reorderLevel;
    }

    public int getBaseUnit() {
        return baseUnit;
    }

    public void setBaseUnit(int baseUnit) {
        this.baseUnit = baseUnit;
    }

    public List<LineItem> getLineItemCollection() {
        return lineItemCollection;
    }

    public void setLineItemCollection(List<LineItem> lineItemCollection) {
        this.lineItemCollection = lineItemCollection;
    }

    public List<MarketReturn> getMarketReturnCollection() {
        return marketReturnCollection;
    }

    public void setMarketReturnCollection(List<MarketReturn> marketReturnCollection) {
        this.marketReturnCollection = marketReturnCollection;
    }

    public Category getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Category categoryId) {
        this.categoryId = categoryId;
    }

    public Discounts getDiscountsId() {
        return discountsId;
    }

    public void setDiscountsId(Discounts discountsId) {
        this.discountsId = discountsId;
    }

    public FreeIssues getFreeIssueId() {
        return freeIssueId;
    }

    public void setFreeIssueId(FreeIssues freeIssueId) {
        this.freeIssueId = freeIssueId;
    }

    public ItemWeight getWeightId() {
        return weightId;
    }

    public void setWeightId(ItemWeight weightId) {
        this.weightId = weightId;
    }

    public List<Damaged> getDamagedCollection() {
        return damagedCollection;
    }

    public void setDamagedCollection(List<Damaged> damagedCollection) {
        this.damagedCollection = damagedCollection;
    }

    public List<ItemDetails> getItemDetailsCollection() {
        return itemDetailsCollection;
    }

    public void setItemDetailsCollection(List<ItemDetails> itemDetailsCollection) {
        this.itemDetailsCollection = itemDetailsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (itemId != null ? itemId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Item)) {
            return false;
        }
        Item other = (Item) object;
        if ((this.itemId == null && other.itemId != null) || (this.itemId != null && !this.itemId.equals(other.itemId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.inventory.entities.Item[itemId=" + itemId + "]";
    }

}
